<template>
  <div class="EmergencyList">
    <div class="flex location-wrap">
      <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/EWManagement' }">预警管理</el-breadcrumb-item>
        <el-breadcrumb-item>预警任务</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="box">
      <!-- 列表筛选 -->
      <filterTitle :lableWidth="'120px'" @query="query" @reset="reset" @change="selectChange"
        @node-click="handleSelectTree" :formData="config.formData" :form="form"></filterTitle>
      <!-- 列表表格 -->
      <LsdTable slot="yjrwlb" :paginationAtrrs="config.table.paginationAtrrs" @pageChange="handleSizeChange"
        :compRef="config.table.compRef" ref="yjrwlb" :columns="config.table.columns" :title="config.table.title"
        :actions="config.table.actions" :tableData="config.table.tableData" :tableAttr="config.table.tableAttr"
        :isShowPage="config.table.isShowPage" :isSelectFlag="config.table.isSelectFlag"
        :isSequenceFlag="config.table.isSequenceFlag" @onActionClick="onActionClick" />
    </div>
    <!-- 任务分配弹窗 -->
    <LsdDialog @handleBtn="onActionClick" :dialogConfig="dialogConfig" @close="close(dialogConfig)">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig" :activeNames="activeNames">
        <DialogForm ref="formComponent" slot="slot1" :formConfig="config.TaskAllocationConfig.formConfig" />
        <div slot="slot2">
          <DialogForm ref="formComponent1" :formConfig="config.TaskAllocationConfig.formConfig1" />
          <LsdTable style="margin-top:20px" :autoHeight="config.TaskAllocationConfig.table.autoHeight" slot="xzdw"
            :compRef="config.TaskAllocationConfig.table.compRef" ref="xzdw"
            :columns="dialogConfig.type === 'approval' ? config.TaskAllocationConfig.table.columns1 : dialogConfig.type === 'edit' ? config.TaskAllocationConfig.table.columns2 : config.TaskAllocationConfig.table.columns"
            :title="config.TaskAllocationConfig.table.title" :actions="config.TaskAllocationConfig.table.actions"
            :tableData="config.TaskAllocationConfig.table.tableData"
            :tableAttr="config.TaskAllocationConfig.table.tableAttr"
            :isShowPage="config.TaskAllocationConfig.table.isShowPage"
            :isSelectFlag="config.TaskAllocationConfig.table.isSelectFlag"
            :isSequenceFlag="config.TaskAllocationConfig.table.isSequenceFlag" @onActionClick="onActionClick" />
        </div>
        <DialogForm ref="formComponent2" slot="slot3" :formConfig="config.TaskAllocationConfig.formConfig2" />
        <DialogForm ref="formComponent3" slot="slot4" :formConfig="config.TaskAllocationConfig.formConfig3" />
      </LsdDialogTitle>
    </LsdDialog>
    <!-- 任务派遣弹窗 -->
    <LsdDialog @handleBtn="onActionClick" :dialogConfig="dialogConfig1" @close="close(dialogConfig1)"
      @beforeClose="beforeClose(dialogConfig1)">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig1" :activeNames="activeNames1">
        <DialogForm ref="formTasking" slot="slot1" :formConfig="config.tasking.formConfig" />
        <DialogForm ref="formTasking1" slot="slot2" :formConfig="config.tasking.formConfig1" />
        <div slot="slot3" class="yqwcsj">
          <el-steps :active="active" align-center>
            <el-step v-for="( item, i ) in  operateFlow " :key="i">
              <template slot="icon">
                <span class="yuandian1 ydBgcolor"></span>
              </template>
              <template slot="title">
                <div style="color:#333333">{{ item.nodeTime }}</div>
              </template>
            </el-step>
          </el-steps>
          <div class="flexAround fontSize18 margin5-0">
            <div v-for="( item, index ) in  operateFlow " :key="index"
              style="display:flex;justify-content: center;flex-direction: column;align-items: center;">
              <div><span style="color:#333333">{{ item.sendDept }}</span></div>
              <div style="color:#333333;font-weight:600">{{ item.taskNode }}</div>
            </div>
          </div>
          <!-- :formConfig="tableShow === null? config.tasking.formConfig2: tableShow? config.tasking.formConfig2: config.tasking.formConfig4" -->
          <DialogForm ref="formTasking2" @change="change" :formConfig="config.tasking.formConfig4" />
          <LsdTable v-if="tableShow" slot="rwpq" :autoHeight="config.tasking.table.autoHeight"
            :compRef="config.tasking.table.compRef" ref="xzdw"
            :columns="dialogConfig1.type === 'taskingEdit' ? config.tasking.table.columns1 : config.tasking.table.columns"
            :title="config.tasking.table.title" :actions="config.tasking.table.actions"
            :tableData="config.tasking.table.tableData" :tableAttr="config.tasking.table.tableAttr"
            :isShowPage="config.tasking.table.isShowPage" :isSelectFlag="config.tasking.table.isSelectFlag"
            :isSequenceFlag="config.tasking.table.isSequenceFlag" @onActionClick="onActionClick" />
        </div>
        <DialogForm ref="formTasking3" slot="slot4" :formConfig="config.tasking.formConfig3" />
      </LsdDialogTitle>
    </LsdDialog>
    <!-- 子任务审批弹窗 -->
    <LsdDialog @handleBtn="onActionClick" :dialogConfig="dialogConfig2" @close="close(dialogConfig2)">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig2" :activeNames="activeNames2">
        <DialogForm ref="childTasking" slot="slot1" :formConfig="config.childTasking.formConfig" />
        <DialogForm ref="childTasking1" slot="slot2" :formConfig="config.childTasking.formConfig1" />
        <div v-for="( item, index ) in  childConfig " :key="index" :slot="item.slot">
          <DialogForm :ref="childFormConfig[index].ref" :formConfig="childFormConfig[index]" />
          <!-- 删除人员表格 -->
          <div style="font-size:16px;margin-left:20px" v-if="childTeamConfig[index].tableData.length > 0">已选队伍：{{
            childTeamConfig[index].tableData[0].teamName }}</div>
          <!-- <LsdTable :autoHeight="childTeamConfig[index].autoHeight" :tableData="childTeamConfig[index].tableData" :columns="childTeamConfig[index].columns" :compRef="childTeamConfig[index].compRef" :accesskey="childTeamConfig[index].compRef" :title="childTeamConfig[index].title" :actions="childTeamConfig[index].actions" :tableAttr="childTeamConfig[index].tableAttr" :isShowPage="childTeamConfig[index].isShowPage" :isSelectFlag="childTeamConfig[index].isSelectFlag" :isSequenceFlag="childTeamConfig[index].isSequenceFlag"  @onActionClick="onActionClick" /> -->
          <div style="font-size:16px;margin:20px 0 0 20px">已选车辆：{{ childEquipmentConfig[index].tableData.length }}</div>
          <LsdTable :autoHeight="childEquipmentConfig[index].autoHeight" :compRef="childEquipmentConfig[index].compRef"
            :ref="childEquipmentConfig[index].compRef" :columns="childEquipmentConfig[index].columns"
            :title="childEquipmentConfig[index].title" :actions="childEquipmentConfig[index].actions"
            :tableData="childEquipmentConfig[index].tableData" :tableAttr="childEquipmentConfig[index].tableAttr"
            :isShowPage="childEquipmentConfig[index].isShowPage" :isSelectFlag="childEquipmentConfig[index].isSelectFlag"
            :isSequenceFlag="childEquipmentConfig[index].isSequenceFlag" @onActionClick="onActionClick" />
          <div style="font-size:16px;margin:20px 0 0 20px">已选装备：{{ childVehicleConfig[index].tableData.length }}</div>
          <LsdTable :autoHeight="childVehicleConfig[index].autoHeight" :compRef="childVehicleConfig[index].compRef"
            :ref="childVehicleConfig[index].compRef" :columns="childVehicleConfig[index].columns"
            :title="childVehicleConfig[index].title" :actions="childVehicleConfig[index].actions"
            :tableData="childVehicleConfig[index].tableData" :tableAttr="childVehicleConfig[index].tableAttr"
            :isShowPage="childVehicleConfig[index].isShowPage" :isSelectFlag="childVehicleConfig[index].isSelectFlag"
            :isSequenceFlag="childVehicleConfig[index].isSequenceFlag" @onActionClick="onActionClick" />
        </div>
        <DialogForm ref="childTasking3" :slot="checkSlot(1)" :formConfig="config.childTasking.formConfig3" />
        <DialogForm ref="childTasking4" :slot="checkSlot(2)" :formConfig="config.childTasking.formConfig4" />
      </LsdDialogTitle>
    </LsdDialog>
    <!-- 队伍选择弹窗 -->
    <DialogChoose ref="dialogChoose" @checkSelect="checkSelect" @handleChooseChange="handleChooseChange"
      @chooseQuery="chooseQuery" :ChooseConfig="ChooseConfig" @close="close" @teamAdd="teamAdd"
      :ChooseFormConfig="checkConfig(1)" :ChooseTableConfig="checkConfig(2)"></DialogChoose>
  </div>
</template>

<script>
// childApproval,approvalTask,submitTask,submitMission,
import { cloneDeep } from "lodash";
import { showTime } from "@/lib";
// import { getUnitTreeApi } from "@/api/EarlyWarningManagement/yjrb";
// import { ssdwList } from "@/api/SystemConfig/userConfig";
// taskDispatch listPage2  feedbackListPage,
import { saveTask, getIssueNoticeList, getTeam, GetEquipType, GetVehicleType, GetListTeamType, listPage, getById, getSpDetail, deleteTask, saveMission, getMission, getDictList } from "@/api/EarlyWarningManagement/yjrw.js";
import { getDictByGroup, GetTeam, GetTeamMember, GetEquip, GetVehicle, getOrggetSameLevel, getSuperiorUntilId, getOrgDepartmentList } from "@/api/common.js";
import { flowSubmit } from "@/utils/flow";
export default {
  data() {
    return {
      rwlxOption: [],
      zrdwOption: [],
      // 任务派遣时间轴
      operateFlow: [],
      status: "", // 为1下派过为0没有下派过
      active: 0,
      config: {},
      form: {},
      rules: {
        useUserName: [
          { required: true, message: "请输入领用人", trigger: "blur" }
        ]
      },
      // 任务分配弹窗
      dialogConfig: {
        title: "",
        isShow: false,
        type: "",
        btnList: [],
        width: "80%"
      },
      // 折叠面板
      titleConfig: [],
      activeNames: ["1", "2", "3", "4", "5"],
      // 任务下派弹窗
      dialogConfig1: {
        title: "",
        isShow: false,
        beforeClose: true,
        type: "",
        btnList: [
          {
            name: "提交",
            type: "primary",
            id: "submitTasking",
            size: "mini"
          },
          {
            name: "保存",
            id: "saveTasking",
            size: "mini"
          },
          {
            name: "取消",
            id: "cancel",
            size: "mini"
          }

        ],
        width: "95%"
      },
      // 折叠面板
      titleConfig1: [],
      activeNames1: ["1", "2", "3", "4", "5"],
      // 子任务审核弹窗
      dialogConfig2: {
        title: "预警子任务派遣单",
        isShow: false,
        type: "childApproval",
        btnList: [
          {
            name: "同意",
            type: "primary",
            id: "agreeChild",
            size: "mini"
          },
          {
            name: "驳回",
            id: "rejectedChild",
            size: "mini"
          },
          {
            name: "取消",
            id: "cancel",
            size: "mini"
          }
        ]
      },
      // 折叠面板
      titleConfig2: [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "主任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        },
        {
          title: "审批信息",
          name: "4",
          slot: "slot4"
        }
      ],
      activeNames2: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
      // 队伍选择弹窗信息
      ChooseConfig: {
        title: "",
        isShow: false,
        checkSelect: false,
        type: "",
        btnList: [],
        index: 0,
        unit: ""
      },
      tableShow: null,
      noticeOption: [],
      // 主任务id
      mainTaskId: "",
      // 主任务关联子任务id
      contactChildId: "",
      forTableData: [],
      childFormConfig: [],
      childTeamConfig: [],
      childEquipmentConfig: [],
      childVehicleConfig: [],
      childConfig: [],
      // 保存选择队伍数据
      teamList: [],
      // 保存选择人员数据
      playerList: [],
      // 保存选择装备数据
      equipmentList: [],
      // 保存选择车辆数据
      vehicleList: [],
      // 选择队伍id
      teamId: "",
      // 派发单位树
      selectTreeList: [],
      professionCode: "",
      profession: ""
    };
  },
  created() {
    this.config = require(`./config`).default.config(this);
    this.config.TaskAllocationConfig = Object.assign({}, this.config.TaskAllocationConfig);
    this.getList();
    this.getTasksOption();
    this.getSearchNoticeOption();
    this.getInputVal();
    // const role = JSON.parse(sessionStorage.getItem("role")).roleCode;
    // if (role === "hb_tbr") {
    //   this.config.table.actions = [
    //     {
    //       id: "add",
    //       text: "任务分配",
    //       type: "primary",
    //       btnAttr: { size: "small" }
    //     }
    //   ];
    // } else {
    //   this.config.table.actions = [];
    // }
  },
  watch: {
    "dialogConfig.type": {
      handler(val) {
        const { orgId } = JSON.parse(sessionStorage.getItem("org"));
        const dwbmName = sessionStorage.getItem("dwbmName");
        const userName = JSON.parse(sessionStorage.getItem("account")).realName;
        const time = showTime(new Date());
        if (val === "add") {
          this.$nextTick(() => {
            this.$set(this.$refs.formComponent1.form, "distributeDept", dwbmName);
            this.$set(this.$refs.formComponent1.form, "distributeDeptId", orgId);
            this.$set(this.$refs.formComponent2.form, "fillUser", userName);
            this.$set(this.$refs.formComponent2.form, "fillUserDept", dwbmName);
            this.$set(this.$refs.formComponent2.form, "fillTime", time);
          });
        } else if (val === "approval") {
          this.$nextTick(() => {
            this.$set(this.$refs.formComponent3.form, "approvalUser", userName);
            this.$set(this.$refs.formComponent3.form, "approvalDept", dwbmName);
            this.$set(this.$refs.formComponent3.form, "approvalTime", time);
          });
        }
      },
      deep: true,
      immediate: true
    },
    "$route.query.flowCode": {
      handler() {
        this.getList();
      },
      deep: true
    }
  },
  methods: {
    // 工作流提交
    gzlSubmit(bizKey, variable, type) {
      let callbackUrl = "/warning/warningDistributionTask/handleFlow";
      let taskId = "task1";
      let idea = "1";
      if (type === 2) {
        taskId = "task3";
        callbackUrl = "/warning/warningSubMainTask/handleFlow";
      } else if (type === 1) {
        idea = "0";
        taskId = "task3";
        callbackUrl = "/warning/warningSubMainTask/handleFlow";
      } else if (type === 0) {
        idea = "0";
        taskId = "task4";
        callbackUrl = "/warning/warningSubMainTask/handleFlow";
      }
      const data = {
        bizKey,
        flowKey: "warning_task_005",
        taskId: taskId,
        callbackUrl: callbackUrl,
        idea: idea,
        variable
      };
      const successCallBack = () => {
        this.$message({
          message: "提交成功",
          type: "success"
        });
        this.getList();
        if (type === 2 || type === 1 || type === 0) {
          this.dialogConfig1.isShow = false;
        } else {
          this.dialogConfig.isShow = false;
        }

      };
      flowSubmit(data, successCallBack, "提交", true);
    },
    // 工作流审批
    gzlAudit(type, variable, types) {
      let callbackUrl = "/warning/warningDistributionTask/handleFlow";
      let ideaMsg = "";
      let taskId = "";
      if (types === 5 || types === 6) {
        ideaMsg = this.$refs.childTasking4.form.approvalOpinion ? this.$refs.childTasking4.form.approvalOpinion : type === 3 ? "同意" : "驳回";
        taskId = "task6";
        callbackUrl = "/warning/warningSubMainTask/handleFlow";
      } else if (types === 55 || types === 66) {
        ideaMsg = this.$refs.childTasking4.form.approvalOpinion ? this.$refs.childTasking4.form.approvalOpinion : type === 3 ? "同意" : "驳回";
        taskId = "task5";
        callbackUrl = "/warning/warningSubMainTask/handleFlow";
      } else {
        ideaMsg = this.$refs.formComponent3.form.approvalOpinion ? this.$refs.formComponent3.form.approvalOpinion : type === 3 ? "同意" : "驳回";
        taskId = "task2";
      }
      const data = {
        bizKey: this.mainTaskId,
        flowKey: "warning_task_005",
        taskId: taskId,
        callbackUrl: callbackUrl,
        idea: type === 3 ? "1" : "0",
        variable,
        ideaMsg: ideaMsg
      };
      const successCallBack = () => {
        this.$message({
          message: `${type === 3 ? "审核" : "驳回"}成功`,
          type: "success"
        });
        if (types === 5 || types === 6 || types === 55 || types === 66) {
          this.$set(this.dialogConfig2, "isShow", false);
          this.getList();
        } else {
          this.dialogConfig.isShow = false;
          this.getList();
        }

      };
      if (types === 6 || types === 5 || types === 8 || types === 55 || types === 66) {
        flowSubmit(data, successCallBack, "审核");
      } else if (types === 7) {
        flowSubmit(data, successCallBack, "审核", true);
      }
    },
    // 任务分配组织机构点击事件
    handleClick(data, item, scope) {
      this.$set(this.config.TaskAllocationConfig.table.tableData[scope.$index], "dutyUnit", data.orgName);
      this.$set(this.config.TaskAllocationConfig.table.tableData[scope.$index], "dutyUnitCode", data.id);
    },
    // 接收单位树
    getUnitTree() {
      // getUnitTreeApi().then(res => {
      const orgId = JSON.parse(sessionStorage.getItem("org")).orgId;
      getOrgDepartmentList({ orgId }).then(res => {
        this.config.tasking.formConfig4.formData[1].treeData.data = res;
      });
    },
    handleSelectTree(arg, item) {
      if (item.id === "distributeDept") {
        this.$set(this.form, "distributeTaskId", arg[0].id);
        this.$set(this.form, "distributeDept", arg[0].orgName);
      } else if (item.id === "dutyUnit") {
        this.$set(this.form, "dutyUnitCode", arg[0].id);
        this.$set(this.form, "dutyUnit", arg[0].orgName);
      }
    },
    // 调用按钮对应方法
    onActionClick(item, index) {
      this[item.id]();
    },
    // 新增
    add(val, scope, hidden) {
      this.getTasksOption();
      this.$nextTick(() => {
        this.$set(this.dialogConfig, "isShow", true);
        if (val) {
          this.$set(this.dialogConfig, "type", "edit");
          this.getTasksDetail(scope);
        } else {
          this.mainTaskId = "";
          this.$set(this.dialogConfig, "type", "add");
        }
        this.$set(this.dialogConfig, "title", "预警任务分配单");
        console.log(this.$refs.formComponent, "?????this.$refs.formComponent1");
        this.$set(this.config.TaskAllocationConfig.formConfig.formData[0], "isDisabled", false);
        this.$set(this.config.TaskAllocationConfig.formConfig, "rules", this.config.TaskAllocationConfig.formConfig.rules1);
        this.$set(this.config.TaskAllocationConfig.formConfig1.formData[1], "isDisabled", false);
        this.$set(this.config.TaskAllocationConfig.formConfig1, "rules", this.config.TaskAllocationConfig.formConfig1.rules1);

        const btnList = [
          {
            name: "提交",
            type: "primary",
            id: "submit",
            size: "mini"
          },
          {
            name: "保存",
            id: "save",
            size: "mini"
          },
          {
            name: "取消",
            id: "cancel",
            size: "mini"
          }
        ];
        this.$set(this.dialogConfig, "btnList", btnList);
        const titleConfig = [
          {
            title: "信息来源",
            name: "1",
            slot: "slot1"
          },
          {
            title: "任务信息",
            name: "2",
            slot: "slot2"
          },
          {
            title: "填报信息",
            name: "3",
            slot: "slot3"
          }
        ];
        this.$set(this, "titleConfig", titleConfig);
      });
      this.getNoticeOption(1);
    },
    // 获取列表
    getList(val) {
      let parmas = {
        pageNum: 1,
        pageSize: 10,
        flowCode: this.$route.query.flowCode || "",
        roleCode: JSON.parse(sessionStorage.getItem("role")).roleCode,
        // orgCode: JSON.parse(sessionStorage.getItem("org")).orgId
        // dutyUnitCode: JSON.parse(sessionStorage.getItem("org")).orgId
        orgCode: JSON.parse(sessionStorage.getItem("org")).orgId
        // dutyUnitCode: JSON.parse(sessionStorage.getItem("org")).id
      };
      if (val) {
        parmas = val;
      }
      if (this.$route.query.id) {
        parmas.noticeId = this.$route.query.id;
      }
      // const {flowCode} = this.$route.query;
      // if (flowCode == "1,4,8,11") {
      //   listPage2(parmas).then(res => {g
      //     this.config.table.paginationAtrrs.total = res.total;
      //     this.config.table.tableData = res.data;
      //   });
      // } else {
      // if (this.$route.query.flowCode) {
      listPage(parmas).then(res => {
        this.config.table.paginationAtrrs.total = res.total;
        this.config.table.tableData = res.data;
      });
      // } else {
      //   // feedbackListPage
      //   feedbackListPage(parmas).then(res => {
      //     console.log(res, "----");
      //     this.config.table.paginationAtrrs.total = res.total;
      //     this.config.table.tableData = res.data;
      //   });
      // }
      // }
    },
    // 任务分配详情
    getTasksDetail(scope) {
      this.mainTaskId = scope.row.id;
      getById({ id: scope.row.id }).then(data => {
        this.$set(this.$refs.formComponent.form, "noticeId", data.noticeId);
        this.$set(this.$refs.formComponent.form, "noticeOrderName", data.noticeOrderName);
        this.$set(this.$refs.formComponent1.form, "distributeDept", data.distributeDept);
        this.$set(this.$refs.formComponent1.form, "reqCompleteTime", data.reqCompleteTime);
        this.$set(this.$refs.formComponent2.form, "fillUser", data.fillUser);
        this.$set(this.$refs.formComponent2.form, "fillUserDept", data.fillUserDept);
        this.$set(this.$refs.formComponent2.form, "fillTime", data.fillTime);
        this.$set(this.config.TaskAllocationConfig.table, "tableData", data.detailVos);
      });
    },
    // 任务派遣详情
    getTaskMission(scope) {
      this.mainTaskId = scope.row.id;
      getMission({ id: scope.row.id }).then(data => {
        console.log(data.mainTask, "mainTaskmainTaskmainTask");
        this.professionCode = data.mainTask.professionCode;
        this.profession = data.mainTask.profession;
        // 通过专业类型获取子任务类型下拉接口
        getDictList({ groupCode: `dic_zy_${Number(data.mainTask.professionCode)}` }).then(res => {
          const option = res.map(i => {
            return {
              label: i.dicName,
              value: i.dicCode
            };
          });
          this.$set(this, "rwlxOption", option);
        });
        this.contactChildId = data.id;
        const result = data.subTaskNodeDetailVos;
        this.status = data.status;
        result.push({
          taskNode: "子任务处置",
          nodeTime: showTime(new Date()),
          sendDept: sessionStorage.getItem("dwbmName"),
          receiveDept: data.mainTask.dutyUnit,
          id: data.subTaskNodeDetailVos[0].id,
          mainTaskId: data.subTaskNodeDetailVos[0].mainTaskId,
          nodeStatus: 2
        });
        // if (data.subTaskNodeDetailVos.length > 1) {
        // }
        this.$set(this, "operateFlow", result);
        console.log(this.contactChildId, "???????????this.contactChildId");
        this.$set(this.$refs.formTasking.form, "noticeId", data.mainTask.noticeId);
        this.$set(this.$refs.formTasking.form, "noticeOrderName", data.mainTask.noticeOrderName);
        this.$set(this.$refs.formTasking1.form, "taskName", data.mainTask.taskName);
        this.$set(this.$refs.formTasking1.form, "taskType", data.mainTask.taskType);
        this.$set(this.$refs.formTasking1.form, "taskTypeCode", data.mainTask.taskTypeCode);
        this.$set(this.$refs.formTasking1.form, "distributeDept", data.mainTask.distributeDept);
        this.$set(this.$refs.formTasking1.form, "approvalUser", data.mainTask.approvalUser);
        this.$set(this.$refs.formTasking1.form, "dutyUnit", data.mainTask.dutyUnit);
        this.$set(this.$refs.formTasking1.form, "profession", data.mainTask.profession);
        this.$set(this.$refs.formTasking1.form, "reqCompleteTime", data.mainTask.reqCompleteTime);
        this.$set(this.$refs.formTasking1.form, "taskContent", data.mainTask.taskContent);
        this.$set(this.$refs.formTasking3.form, "fillUser", JSON.parse(sessionStorage.getItem("account")).realName);
        this.$set(this.$refs.formTasking3.form, "fillUserDept", sessionStorage.getItem("dwbmName"));
        this.$set(this.$refs.formTasking3.form, "fillTime", showTime(new Date()));
        this.$set(this.$refs.formTasking2.form, "subTaskStatus", data.subTaskStatus || "1");
        this.$set(this.$refs.formTasking2.form, "dispatchDept", data.dispatchDept);
        this.$set(this.$refs.formTasking2.form, "dispatchDeptId", data.dispatchDeptId);
        if (data.subTaskStatus === "0") {
          this.config.tasking.formConfig4.formData = [
            {
              type: "radio",
              label: "任务处置",
              prop: "subTaskStatus",
              class: "half",
              lableWidth: "140px",
              radio: [
                {
                  label: "下派",
                  value: "0",
                  isDisabled: false
                },
                {
                  label: "执行",
                  value: "1",
                  isDisabled: true
                }
              ]
            },
            {
              type: "selectTree",
              label: "接收单位",
              prop: "dispatchDept",
              name: "dispatchDeptId",
              title: "接收单位选择",
              choose: false,
              commonClick: true,
              isSplice: true,
              chooseUnit: true,
              ref: "tree_select1",
              class: "half",
              multiple: false,
              lableWidth: "140px",
              option: [],
              treeData: {
                data: [],
                checked: [],
                props: {
                  children: "children",
                  label: "orgName",
                  value: "id"
                }
              }
            }
          ];
          this.tableShow = false;
          // this.$set(this.config.tasking.formConfig2.formData[0].radio[1], "isDisabled", true);
        } else if (data.subTaskStatus === "1") {
          this.config.tasking.formConfig4.formData = [
            {
              type: "radio",
              label: "任务处置",
              prop: "subTaskStatus",
              class: "half",
              lableWidth: "140px",
              radio: [
                {
                  label: "下派",
                  value: "0",
                  isDisabled: true
                },
                {
                  label: "执行",
                  value: "1",
                  isDisabled: false
                }
              ]
            }
          ];
          this.tableShow = true;
          // this.$set(this.config.tasking.formConfig4.formData[0].radio[0], "isDisabled", true);
        } else {
          this.config.tasking.formConfig4.formData = [
            {
              type: "radio",
              label: "任务处置",
              prop: "subTaskStatus",
              class: "half",
              lableWidth: "140px",
              radio: [
                {
                  label: "下派",
                  value: "0",
                  isDisabled: false
                },
                {
                  label: "执行",
                  value: "1",
                  isDisabled: false
                }
              ]
            }
          ];
          this.tableShow = true;
        }

        const level = JSON.parse(sessionStorage.getItem("org")).level;
        if (level === 3) {
          this.$set(this.config.tasking.formConfig4.formData[0], "radio", [
            {
              label: "执行",
              value: "1",
              isDisabled: false
            }
          ]);
        }
        // this.change(data.subTaskStatus || "1");
        const { orgId } = JSON.parse(sessionStorage.getItem("org"));
        const dwbmName = sessionStorage.getItem("dwbmName");
        if (data.subTaskDetailVoList.length > 0) {
          this.$set(this.config.tasking.table, "tableData", data.subTaskDetailVoList);
        } else {
          this.$nextTick(() => {
            this.$set(this.config.tasking.table.tableData[0], "subDutyDept", dwbmName);
            this.$set(this.config.tasking.table.tableData[0], "subDutyDeptCode", orgId);
            this.$set(this.config.tasking.table.tableData[0], "subTaskCode", data.mainTask.taskTypeCode);
            this.$set(this.config.tasking.table.tableData[0], "subTaskType", data.mainTask.taskType);
            this.$set(this.config.tasking.table.tableData[0], "subReqDoneTime", data.mainTask.reqCompleteTime);
          });
        }
      });
    },
    checkSlot(val) {
      const config = this.titleConfig2[this.titleConfig2.length - 3];
      const slot = config.slot.split("");
      this.titleConfig2[this.titleConfig2.length - 2].slot = "slot" + (Number(slot[slot.length - 1]) + 1);
      this.titleConfig2[this.titleConfig2.length - 2].name = String(Number(slot[slot.length - 1]) + 1);
      this.titleConfig2[this.titleConfig2.length - 1].slot = "slot" + (Number(slot[slot.length - 1]) + 2);
      this.titleConfig2[this.titleConfig2.length - 1].name = String(Number(slot[slot.length - 1]) + 2);
      if (val === 1) {
        return "slot" + (Number(slot[slot.length - 1]) + 1);
      } else {
        return "slot" + (Number(slot[slot.length - 1]) + 2);
      }
    },
    checkChildConfig(scope) {
      getSpDetail({ id: scope.row.id }).then(data => {
        data.subTaskDetailVos.forEach((item, index) => {
          this.childConfig.splice((index), 0, { title: "子任务" + (index + 1), slot: "slot" + (3 + index), name: String(3 + index) });
          this.titleConfig2.splice((2 + index), 0, { title: "子任务" + (index + 1), slot: "slot" + (3 + index), name: String(3 + index) });
          let childFormConfig = "config" + (index + 2);
          let childTeamConfig = "config" + (index + 2);
          let childEquipmentConfig = "config" + (index + 2);
          let childVehicleConfig = "config" + (index + 2);
          childFormConfig = cloneDeep(this.config.childTasking.formConfig2);
          childTeamConfig = cloneDeep(this.config.childTasking.table);
          childEquipmentConfig = cloneDeep(this.config.childTasking.table1);
          childVehicleConfig = cloneDeep(this.config.childTasking.table2);
          childFormConfig.ref = "childFormConfig";
          childTeamConfig.compRef = "rylb" + (index + 1);
          childEquipmentConfig.compRef = "zblb" + (index + 1);
          childVehicleConfig.compRef = "cllb" + (index + 1);
          this.childFormConfig[index] = childFormConfig;
          this.childTeamConfig.splice(index, 0, childTeamConfig);
          this.childEquipmentConfig.splice(index, 0, childEquipmentConfig);
          this.childVehicleConfig.splice(index, 0, childVehicleConfig);
        });
        const config = this.titleConfig2[this.titleConfig2.length - 3];
        const slot = config.slot.split("");
        this.titleConfig2[this.titleConfig2.length - 2].slot = "slot" + (Number(slot[slot.length - 1]) + 1);
        this.titleConfig2[this.titleConfig2.length - 2].name = (Number(slot[slot.length - 1]) + 1);
        this.titleConfig2[this.titleConfig2.length - 1].slot = "slot" + (Number(slot[slot.length - 1]) + 2);
        this.titleConfig2[this.titleConfig2.length - 1].name = (Number(slot[slot.length - 1]) + 2);
        const arr = [];
        this.titleConfig2.forEach((i, j) => {
          arr.push(String(j + 1));
        });
        this.$set(this, "activeNames2", arr);
      });

    },
    // 审批子任务详情
    getApprovalDetail(scope) {
      getSpDetail({ id: scope.row.id }).then(data => {
        this.$nextTick(() => {
          this.mainTaskId = data.mainTaskId;
          this.contactChildId = data.id;
          this.status = data.status;
          this.$set(this.$refs.childTasking.form, "noticeId", data.mainTaskDetailVo.noticeId);
          this.$set(this.$refs.childTasking.form, "noticeOrderName", data.mainTaskDetailVo.noticeOrderName);
          this.$set(this.$refs.childTasking1.form, "taskName", data.mainTaskDetailVo.taskName);
          this.$set(this.$refs.childTasking1.form, "taskType", data.mainTaskDetailVo.taskType);
          this.$set(this.$refs.childTasking1.form, "taskTypeCode", data.mainTaskDetailVo.taskTypeCode);
          this.$set(this.$refs.childTasking1.form, "distributeDept", data.mainTaskDetailVo.distributeDept);
          this.$set(this.$refs.childTasking1.form, "fillUser", data.mainTaskDetailVo.fillUser);
          this.$set(this.$refs.childTasking1.form, "dutyUnit", data.mainTaskDetailVo.dutyUnit);
          this.$set(this.$refs.childTasking1.form, "profession", data.mainTaskDetailVo.profession);
          this.$set(this.$refs.childTasking1.form, "professionCode", data.mainTaskDetailVo.professionCode);
          this.$set(this.$refs.childTasking1.form, "reqCompleteTime", data.mainTaskDetailVo.reqCompleteTime);
          this.$set(this.$refs.childTasking1.form, "taskContent", data.mainTaskDetailVo.taskContent);
          this.$set(this.$refs.childTasking3.form, "fillUser", data.fillUser);
          this.$set(this.$refs.childTasking3.form, "fillUserDept", data.fillUserDept);
          this.$set(this.$refs.childTasking3.form, "fillTime", data.fillTime);
          this.$set(this.$refs.childTasking4.form, "approvalUser", JSON.parse(sessionStorage.getItem("account")).realName);
          this.$set(this.$refs.childTasking4.form, "approvalDept", sessionStorage.getItem("dwbmName"));
          this.$set(this.$refs.childTasking4.form, "approvalTime", showTime(new Date()));
          // this.childFormConfig.forEach((item, index) => {
          data.subTaskDetailVos.forEach((i, j) => {
            this.$nextTick(() => {
              this.$set(this.$refs.childFormConfig[j].form, "subTaskName", i.subTaskName);
              this.$set(this.$refs.childFormConfig[j].form, "subTaskType", i.subTaskType);
              this.$set(this.$refs.childFormConfig[j].form, "subDutyDept", i.subDutyDept);
              this.$set(this.$refs.childFormConfig[j].form, "planStartTime", i.planStartTime);
              this.$set(this.$refs.childFormConfig[j].form, "planCompleteTime", i.planCompleteTime);
              this.$set(this.$refs.childFormConfig[j].form, "needNum", i.needNum ? i.needNum + "人" : "");
              // this.$set(this.$refs.childFormConfig[j].form, "subReportPeriod", i.subReportPeriod + "小时");
              // 删除人员表格
              this.$set(this.childTeamConfig[j], "tableData", i.teamList);
              this.$set(this.childEquipmentConfig[j], "tableData", i.vehicleList);
              this.$set(this.childVehicleConfig[j], "tableData", i.equipList);
            });
          });
          // })
        });
      });
    },
    // 子任务同意
    agreeChild() {
      this.childTaskApproval("pass");
    },
    // 子任务驳回
    rejectedChild() {
      this.childTaskApproval("reject");
    },
    // 子任务审批
    childTaskApproval(val) {
      const parmas = {
        mainTaskId: this.mainTaskId,
        id: this.contactChildId,
        approveSign: val,
        approvalOpinion: this.$refs.childTasking4.form.approvalOpinion,
        approvalUser: this.$refs.childTasking4.form.approvalUser,
        approvalDept: this.$refs.childTasking4.form.approvalDept,
        approvalTime: this.$refs.childTasking4.form.approvalTime
      };
      // childApproval(parmas).then(res => {
      // if (res) {
      if (this.status === "1") {
        if (val === "reject") {
          this.gzlAudit(4, parmas, 66);
        } else if (val === "pass") {
          this.gzlAudit(3, parmas, 55);
        }
      } else if (this.status === "0") {
        if (val === "reject") {
          this.gzlAudit(4, parmas, 6);
        } else if (val === "pass") {
          this.gzlAudit(3, parmas, 5);
        }
      }


      // this.$message({
      //   message: "审批成功！",
      //   type: "success"
      // });
      // this.$set(this.dialogConfig2, "isShow", false);
      // this.getList();
      // }
      // });
    },
    // 列表选队伍
    selectTeam(row) {
      this.dialogConfig.isShow = true;
      this.dialogConfig.type = "select";
      this.dialogConfig.title = "行动队伍选择";
      this.dialogConfig.btnList = [
        {
          name: "提交",
          type: "primary",
          id: "submit",
          size: "mini"
        },
        {
          name: "保存",
          id: "save",
          size: "mini"
        },
        {
          name: "取消",
          id: "cancel",
          size: "mini"
        }
      ];
      this.titleConfig = [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "队伍信息",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.formConfig.disabled = true;
      this.formConfig1.disabled = true;
    },
    // 列表跳预警通知单
    listDetail(row) {
      this.$router.push({
        path: "/WarningActionDetail"
      });
    },
    //  任务处置change事件
    change(item) {
      if (this.$refs.formTasking2.form.subTaskStatus === item) {
        if (item === "0") {
          this.getUnitTree();
          const result = this.operateFlow.slice(0, -1);
          result.push({
            taskNode: "子任务下派",
            nodeTime: showTime(new Date()),
            sendDept: sessionStorage.getItem("dwbmName"),
            receiveDept: result[0].receiveDept,
            id: result[0].id,
            mainTaskId: result[0].mainTaskId,
            nodeStatus: 2
          });
          this.$set(this, "operateFlow", result);
          this.config.tasking.formConfig4.formData = [
            {
              type: "radio",
              label: "任务处置",
              prop: "subTaskStatus",
              class: "half",
              lableWidth: "140px",
              radio: [
                {
                  label: "下派",
                  value: "0",
                  isDisabled: false
                },
                {
                  label: "执行",
                  value: "1",
                  isDisabled: false
                }
              ]
            },
            {
              type: "selectTree",
              label: "接收单位",
              prop: "dispatchDept",
              name: "dispatchDeptId",
              keyWord: "keyWord",
              treeRef: "treeRef",
              commonClick: true,
              isSplice: true,
              chooseUnit: true,
              clickClose: true,
              title: "接收单位选择",
              choose: false,
              ref: "tree_select1",
              class: "half",
              multiple: false,
              lableWidth: "140px",
              option: [],
              treeData: {
                data: [],
                checked: [],
                props: {
                  children: "children",
                  label: "orgName",
                  value: "id"
                }
              }
            }
          ];
          const btnList = [
            {
              name: "提交",
              type: "primary",
              id: "submitTasking",
              size: "mini"
            },
            {
              name: "取消",
              id: "cancel",
              size: "mini"
            }
          ];
          this.$set(this.dialogConfig1, "btnList", btnList);
          this.tableShow = false;
        } else if (item === "1") {
          const result = this.operateFlow.slice(0, -1);
          result.push({
            taskNode: "子任务处置",
            nodeTime: showTime(new Date()),
            sendDept: sessionStorage.getItem("dwbmName"),
            receiveDept: result[0].receiveDept,
            id: result[0].id,
            mainTaskId: result[0].mainTaskId,
            nodeStatus: 2
          });
          this.$set(this, "operateFlow", result);
          this.tableShow = true;
          this.config.tasking.formConfig4.formData = [
            {
              type: "radio",
              label: "任务处置",
              prop: "subTaskStatus",
              class: "half",
              lableWidth: "140px",
              radio: [
                {
                  label: "下派",
                  value: "0",
                  isDisabled: false
                },
                {
                  label: "执行",
                  value: "1",
                  isDisabled: false
                }
              ]
            }
          ];
          const btnList = [
            {
              name: "提交",
              type: "primary",
              id: "submitTasking",
              size: "mini"
            },
            {
              name: "保存",
              id: "saveTasking",
              size: "mini"
            },
            {
              name: "取消",
              id: "cancel",
              size: "mini"
            }
          ];
          this.$set(this.dialogConfig1, "btnList", btnList);
        }
      }
    },
    // 弹窗关闭
    close(val) {
      if (["add", "approval", "edit"].includes(val.type)) {
        console.log(123);
        if (["approval"].includes(val.type)) {
          this.$refs.formComponent3.form.approvalOpinion = "";
        }
        this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
        this.$refs.formComponent1.form = this.$refs.formComponent1.$options.data().form;
        const tableData = [
          {
            taskName: "",
            dutyUnitCode: "",
            taskTypeCode: "",
            professionCode: "",
            taskContent: ""
          }
        ];
        this.$set(this.config.TaskAllocationConfig.table, "tableData", tableData);
        this.$nextTick(() => {
          this.$refs.formComponent.$refs.formInlines.clearValidate();
          this.$refs.formComponent1.$refs.formInlines.clearValidate();
          this.$refs.formComponent2.$refs.formInlines.clearValidate();
          this.$refs.formComponent2.$refs.formInlines.resetFields();
        });
      } else if (["tasking", "taskingEdit"].includes(val.type)) {
        this.$refs.formTasking.form = this.$refs.formTasking.$options.data().form;
        this.$refs.formTasking1.form = this.$refs.formTasking1.$options.data().form;
        this.$refs.formTasking2.form = this.$refs.formTasking2.$options.data().form;
        this.tableShow = null;
        const tableData = [
          {
            subTaskName: "",
            subDutyDeptCode: "",
            subDutyDept: "",
            subTaskType: "",
            subTaskCode: "",
            subReportPeriod: "",
            subReqDoneTime: "",
            isTeam: 0,
            isEquipment: 0,
            isVehicle: 0
          }
        ];
        this.$set(this.config.tasking.table, "tableData", tableData);
        console.log(this.config.tasking.table, tableData, "???tableData");
        this.$nextTick(() => {
          this.$refs.formTasking.$refs.formInlines.clearValidate();
          this.$refs.formTasking1.$refs.formInlines.clearValidate();
          this.$refs.formTasking2.$refs.formInlines.clearValidate();
        });
      }
      this.childConfig = [];
      this.titleConfig2 = [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "主任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        },
        {
          title: "审批信息",
          name: "4",
          slot: "slot4"
        }
      ];
      val.isShow = false;
      val.type = "";
    },
    // 去掉人员选择
    // beforeClose(val) {
    //   if (val.type === "tasking") {
    //     console.log(this.config, "????this.confg.tasking.table.tableData");
    //     const result = this.config.tasking.table.tableData;
    //     const ids = [];
    //     if (result.length > 0) {
    //       result.forEach((item, index) => {
    //         if (item.isTeam === 1) {
    //           ids.push(...item.choiceMemberId);
    //           this.$confirm("关闭后会将新增子任务选中的队伍、人员、装备、车辆清空, 是否继续?", "提示", {
    //             confirmButtonText: "确定",
    //             cancelButtonText: "取消",
    //             type: "warning"
    //           }).then(() => {
    //             // if (item.isTeam === 1) {
    //             updateStatus({ ids: ids.join(","), memberStatus: "readiness" });
    //             // }
    //             // else if (item.isEquipment === 1) {
    //             //   updateEquip({ ids: item.choiceEquId.join(","), memberStatus: "readiness" });
    //             // } else if (item.isVehicle === 1) {
    //             //   updateVehicle({ ids: item.choiceVehicleId.join(","), memberStatus: "readiness" })
    //             // }
    //             this.close(val);
    //             this.$message({
    //               type: "success",
    //               message: "清空成功!"
    //             });
    //           }).catch(() => {
    //             this.$message({
    //               type: "info",
    //               message: "已取消"
    //             });
    //           });
    //         } else {
    //           this.close(val);
    //         }
    //       });
    //     }
    //   } else if (val.type === "taskingEdit") {
    //     const result = cloneDeep(this.config.tasking.table.tableData, {});
    //     const ids = [];
    //     result.forEach((i, index) => {
    //       if (i.id) {
    //         result.splice(index, 1);
    //       }
    //     });
    //     console.log(result);
    //     if (result.length > 0) {
    //       result.forEach((item, index) => {
    //         if (item.isTeam === 1) {
    //           ids.push(...item.choiceMemberId);
    //           // if (item.isTeam === 1 || item.isEquipment === 1 || item.isVehicle === 1) {
    //           this.$confirm("此操作会将子任务选中的队伍、人员、装备、车辆清空, 是否继续?", "提示", {
    //             confirmButtonText: "确定",
    //             cancelButtonText: "取消",
    //             type: "warning"
    //           }).then(() => {
    //             if (item.isTeam === 1) {
    //               updateStatus({ ids: ids.join(","), memberStatus: "readiness" });
    //             }
    //             // else if (item.isEquipment === 1) {
    //             //   updateEquip({ ids: item.choiceEquId.join(","), memberStatus: "readiness" });
    //             // } else if (item.isVehicle === 1) {
    //             //   updateVehicle({ ids: item.choiceVehicleId.join(","), memberStatus: "readiness" })
    //             // }
    //             this.close(val);
    //             this.$message({
    //               type: "success",
    //               message: "清空成功!"
    //             });
    //           }).catch(() => {
    //             this.$message({
    //               type: "info",
    //               message: "已取消"
    //             });
    //           });
    //         } else {
    //           this.close(val);
    //         }
    //       });
    //     } else {
    //       this.close(val);
    //     }
    //   } else {
    //     this.close(val);
    //     // val.isShow = false;
    //     // val.type = "";
    //   }
    // },
    // 提交
    submit() {
      this.save("submit");
    },
    // 保存
    async save(val) {
      this.$refs.formComponent.isValidate();
      this.$refs.formComponent1.isValidate();
      const flag = this.$refs.formComponent.flag;
      const flag1 = this.$refs.formComponent1.flag;
      let emptFlag = true;
      const newTableData = this.config.TaskAllocationConfig.table.tableData;
      console.log(newTableData, "newTableDatanewTableData");
      newTableData.forEach((item, index) => {
        if (item.taskName === "" || item.taskName === null || item.taskName === undefined) {
          this.$message({
            message: `任务信息列表，第${index + 1}条任务名称不能为空`,
            type: "error"
          });
          emptFlag = false;
        } else if (item.dutyUnitCode === "" || item.dutyUnitCode === null || item.dutyUnitCode === undefined) {
          this.$message({
            message: `任务信息列表，第${index + 1}条责任单位/部门不能为空`,
            type: "error"
          });
          emptFlag = false;
        } else if (item.taskTypeCode === "" || item.taskTypeCode === null || item.taskTypeCode === undefined) {
          this.$message({
            message: `任务信息列表，第${index + 1}条任务类型不能为空`,
            type: "error"
          });
          emptFlag = false;
        } else if (item.professionCode === "" || item.professionCode === null || item.professionCode === undefined) {
          this.$message({
            message: `任务信息列表，第${index + 1}条专业类型不能为空`,
            type: "error"
          });
          emptFlag = false;
        } else if (item.taskContent === "" || item.taskContent === null || item.taskContent === undefined) {
          this.$message({
            message: `任务信息列表，第${index + 1}条任务内容不能为空`,
            type: "error"
          });
          emptFlag = false;
        }
      });
      if (flag && flag1 && emptFlag) {
        if (this.dialogConfig.isShow) {
          this.config.TaskAllocationConfig.table.tableData.map(i => {
            i.noticeId = this.$refs.formComponent.form.noticeId;
            i.id = this.mainTaskId || "";
          });
          const parmas = {
            noticeId: this.$refs.formComponent.form.noticeId,
            noticeOrderName: this.$refs.formComponent.form.noticeOrderName,
            distributeDept: sessionStorage.getItem("dwbmName"),
            reqCompleteTime: this.$refs.formComponent1.form.reqCompleteTime,
            saveDtoList: this.config.TaskAllocationConfig.table.tableData,
            id: this.mainTaskId || "",
            fillUserOrgId: JSON.parse(sessionStorage.getItem("org")).orgId
          };
          if (!["agree", "rejected"].includes(val)) {
            parmas.fillUser = JSON.parse(sessionStorage.getItem("account")).realName;
            parmas.fillUserDept = sessionStorage.getItem("dwbmName");
          } else {
            parmas.fillUser = this.$refs.formComponent2.form.fillUser;
            parmas.fillUserDept = this.$refs.formComponent2.form.fillUserDept;
          }
          if (val === "submit") {
            parmas.distributeDeptCode = JSON.parse(sessionStorage.getItem("org")).orgId;
            // if (this.mainTaskId) {
            parmas.id = this.mainTaskId;
            const res = await saveTask(parmas);
            if (res) {
              this.gzlSubmit(res, parmas);
            }
            // }
            //  else {
            //   const res = await submitTask(parmas);
            //   if (res) {
            //     this.gzlSubmit(res, parmas);
            //   }
            // }
            // submitTask(parmas).then(data => {
            //   console.log(data, "data");
            //   if (data) {
            //     this.$message({
            //       message: "提交成功",
            //       type: "success"
            //     });
            //     this.getList();
            //     this.dialogConfig.isShow = false;
            //   }
            // });
          } else if (val === "agree") {
            parmas.saveDtoList.map(i => {
              i.approveSign = "pass";
            });
            parmas.approveSign = "pass";
            parmas.approvalOpinion = this.$refs.formComponent3.form.approvalOpinion || "";
            parmas.id = this.config.TaskAllocationConfig.table.tableData[0].id;
            parmas.approvalDept = sessionStorage.getItem("dwbmName");
            parmas.approvalUser = JSON.parse(sessionStorage.getItem("account")).realName;
            // approvalTask(parmas).then(data => {
            //   if (data) {
            this.gzlAudit(3, parmas, 7);
            // this.$message({
            //   message: "审批已通过",
            //   type: "success"
            // });
            // this.getList();
            // this.dialogConfig.isShow = false;
            //   }
            // });
          } else if (val === "rejected") {
            parmas.saveDtoList.map(i => {
              i.approveSign = "reject";
            });
            parmas.approveSign = "reject";
            parmas.id = this.config.TaskAllocationConfig.table.tableData[0].id;
            parmas.approvalOpinion = this.$refs.formComponent3.form.approvalOpinion || "";
            parmas.approvalUser = sessionStorage.getItem("dwbmName");
            parmas.approvalDept = JSON.parse(sessionStorage.getItem("account")).realName;
            // approvalTask(parmas).then(data => {
            // if (data) {
            this.gzlAudit(4, parmas, 8);
            // this.$message({
            //   message: "审批已驳回",
            //   type: "success"
            // });
            // this.getList();
            // this.dialogConfig.isShow = false;
            // }
            // });
          } else {
            if (this.dialogConfig.type === "add") {
              parmas.distributeDeptCode = JSON.parse(sessionStorage.getItem("org")).orgId;
              saveTask(parmas).then(data => {
                if (data) {
                  this.$message({
                    message: "保存成功",
                    type: "success"
                  });
                  this.getList();
                  this.dialogConfig.isShow = false;
                }
              });
            } else if (this.dialogConfig.type === "edit") {

              parmas.saveDtoList.map(i => {
                i.id = this.mainTaskId;
              });
              saveTask(parmas).then(data => {
                if (data) {
                  this.$message({
                    message: "修改成功",
                    type: "success"
                  });
                  this.getList();
                  this.dialogConfig.isShow = false;
                }
              });
            }
          }
        }
      }
    },
    // 任务派遣保存、提交
    saveTasking(val) {
      console.log(this.config.tasking.table.tableData, "this.config.tasking.table.tableDatathis.config.tasking.table.tableData");
      let emptFlag = true;
      const subTaskStatus = this.$refs.formTasking2.form.subTaskStatus;
      if (subTaskStatus === "1") {
        const newTableData = this.config.tasking.table.tableData;
        newTableData.forEach((item, index) => {
          if (item.subTaskName === "" || item.subTaskName === null || item.subTaskName === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条子任务名称不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.subDutyDeptCode === "" || item.subDutyDeptCode === null || item.subDutyDeptCode === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条责任单位/部门不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.subTaskCode === "" || item.subTaskCode === null || item.subTaskCode === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条任务类型不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.subTaskContent === "" || item.subTaskContent === null || item.subTaskContent === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条任务内容不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.planStartTime === "" || item.planStartTime === null || item.planStartTime === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条计划开始时间不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.planCompleteTime === "" || item.planCompleteTime === null || item.planCompleteTime === undefined) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条计划结束时间不能为空`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.isTeam === 0) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条请选择队伍`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.isEquipment === 0) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条请选择装备`,
              type: "error"
            });
            emptFlag = false;
          } else if (item.isVehicle === 0) {
            this.$message({
              message: `子任务派遣信息列表，第${index + 1}条请选择车辆`,
              type: "error"
            });
            emptFlag = false;
          }
          // else if (item.subReqDoneTime === "" || item.subReqDoneTime === null || item.subReqDoneTime === undefined) {
          //   this.$message({
          //     message: `子任务派遣信息列表，第${index + 1}条要求完成时间不能为空`,
          //     type: "error"
          //   });
          //   emptFlag = false;
          // } else if (item.subReportPeriod === "" || item.subReportPeriod === null || item.subReportPeriod === undefined) {
          //   this.$message({
          //     message: `子任务派遣信息列表，第${index + 1}条上报时间间隔不能为空`,
          //     type: "error"
          //   });
          //   emptFlag = false;
          // }
        });
      }
      if (emptFlag) {
        const parmas = {
          mainTaskId: this.mainTaskId,
          subTaskStatus: this.$refs.formTasking2.form.subTaskStatus,
          creator: JSON.parse(sessionStorage.getItem("account")).realName,
          creatorId: JSON.parse(sessionStorage.getItem("account")).id,
          fillUserDept: sessionStorage.getItem("dwbmName"),
          nodeSaveDto: this.operateFlow
        };
        if (subTaskStatus === "1") {
          parmas.saveDtoList = this.config.tasking.table.tableData;
          // subProfessionCode;
          // subProfession
          parmas.saveDtoList.map(i => {
            i.mainTaskId = this.mainTaskId || "";
            i.subProfessionCode = this.professionCode;
            i.subProfession = this.profession;
          });
          console.log(parmas.saveDtoList, "parmas.saveDtoListparmas.saveDtoList");
        } else {
          parmas.dispatchDept = this.$refs.formTasking2.form.dispatchDept;
          parmas.dispatchDeptId = this.$refs.formTasking2.form.dispatchDeptId;
          // if (val) {
          //   taskDispatch(parmas, 2).then(res => {
          //     if (res) {
          //       this.$message({
          //         message: "保存成功",
          //         type: "success"
          //       });
          //       this.getList();
          //       this.dialogConfig1.isShow = false;
          //     }
          //   });
          // } else {
          //   taskDispatch(parmas, 1).then(res => {
          //     if (res) {
          //       this.$message({
          //         message: "保存成功",
          //         type: "success"
          //       });
          //       this.getList();
          //       this.dialogConfig1.isShow = false;
          //     }
          //   });
          // }
        }
        if (val) {
          saveMission(parmas).then(data => {
            if (data) {
              if (subTaskStatus === "1") {
                if (this.status === "1") {
                  this.gzlSubmit(this.mainTaskId, parmas, 0);
                } else if (this.status === "0") {
                  this.gzlSubmit(this.mainTaskId, parmas, 2);
                }
              } else {
                this.gzlSubmit(this.mainTaskId, parmas, 1);
              }

              // this.$message({
              //   message: "提交成功",
              //   type: "success"
              // });
              // this.getList();
              // this.dialogConfig1.isShow = false;
            }
          });
        } else {
          saveMission(parmas).then(data => {
            if (data) {
              this.$message({
                message: "保存成功",
                type: "success"
              });
              this.getList();
              this.dialogConfig1.isShow = false;
            }
          });
        }
        // if (this.dialogConfig1.type === "taskingEdit") {
        //   parmas.id = this.contactChildId || ""
        // }

      }

    },
    // 任务派遣提交
    submitTasking() {
      this.saveTasking("submitTasking");
    },
    // 列表删除
    handleDelete(scope) {
      this.$confirm("此操作将永久删除该条数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteTask({ id: scope.row.id }).then(data => {
          if (data) {
            this.$message({
              message: "删除成功",
              type: "success"
            });
            this.getList();
          }
        });
      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除"
        });
      });
    },
    // 取消
    cancel() {
      if (this.$refs.formComponent3) {
        this.$refs.formComponent3.form.approvalOpinion = "";
      }
      if (["taskingEdit", "tasking"].includes(this.dialogConfig1.type)) {
        // this.beforeClose(this.dialogConfig1);
        this.close(this.dialogConfig1);
      } else {
        this.dialogConfig.isShow = false;
      }
    },
    selectChange(val) {
      console.log(val);
    },
    // 审批同意
    agree() {
      this.save("agree");
    },
    // 审批驳回
    rejected() {
      this.save("rejected");
    },
    checkRowStyle(row, rowIndex) {
      const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceMemberId || [];
      const styleJson = {};
      if (row.occupation === 1) {
        if (!result.includes(row.id)) {
          styleJson.backgroundColor = "#e7eeff";
          return styleJson;
        }
      }
    },
    // 选择队员、装备、车辆前检查状态
    checkSelect(val, selection) {
      const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceMemberId || [];
      if (val.length > 0) {
        val.forEach((item, index) => {
          if (item.occupation === 1) {
            if (this.ChooseConfig.type === "playersChoose") {
              // 判断是否是回显状态
              if (result.includes(item.id)) {
                this.$refs.dialogChoose.selection = val;
              } else {
                this.$message.error("当前队员为非待命状态");
                this.$refs.dialogChoose.$refs.playerTabel.cancelSelect(item.id);
              }
            }
          } else {
            this.$refs.dialogChoose.selection = val;
          }
        });
      }
    },
    // 选择队伍后往列表添加数据 确定按钮
    teamAdd(item, selecetion) {
      console.log("xxxx");
      if (item.type === "teamChoose") {
        if (selecetion.length > 1) {
          this.$message.error("只能选择一只队伍！");
          return;
        }
        if (selecetion.length === 0) {
          this.$message.error("请选择一只队伍！");
          return;
        }
        // if (this.teamList > 0) {
        //   this.teamList.push(...selecetion)
        // } else {
        const choiceTeamId = selecetion.map(i => { return i.id; });
        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "choiceTeamId", choiceTeamId);
        console.log(this.config.tasking.table.tableData[this.ChooseConfig.index].choiceTeamId, "?????????choiceTeamId");
        // }
        // 预警子任务派遣单去掉选择人员
        // this.ChooseConfig.title = "队员选择";
        // this.ChooseConfig.type = "playersChoose";
        // this.ChooseConfig.unit = "名人员";
        // this.teamId = selecetion[0].id;
        // this.getPlayerList(selecetion);
        this.$set(this.ChooseConfig, "checkSelect", true);
        this.$set(this.$refs.dialogChoose, "selection", []);
        this.$set(this.$refs.dialogChoose.$refs.teamTabel, "selection", []);
        // this.$refs.dialogChoose.selection = [];
        console.log(this.$refs.dialogChoose.selection, "????this.$refs.dialogChoose.selection");

        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "isTeam", 1);
        this.ChooseConfig.isShow = false;
      } else if (item.type === "playersChoose") { // 去掉选择队员弹窗
        // console.log(selecetion, "???selecetion");
        // if (selecetion.length === 0) {
        //   this.$message.error("请选择队员！");
        //   return;
        // }
        // // 获取上次选择的id
        // const beforeSelect = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceMemberId || [];
        // console.log(beforeSelect, ">>>>>>>beforeSelect");
        // // 获取当前选择的id
        // const choiceMemberId = selecetion.map(i => { return i.id; });
        // console.log(choiceMemberId, ">>>>>>now select");
        // // 回显时取消上次选择的队员
        // const cancelSelect = [];
        // beforeSelect.forEach((item, index) => {
        //   if (!choiceMemberId.includes(item)) {
        //     cancelSelect.push(item);
        //   }
        // });
        // console.log(cancelSelect, ">>>>>取消上次选择的队员");
        // // 将取消的队员状态改为待命
        // if (cancelSelect.length > 0) {
        //   updateStatus({ ids: cancelSelect.join(","), memberStatus: "readiness" });
        // }
        // // 更改选中的队员状态
        // updateStatus({ ids: choiceMemberId.join(","), memberStatus: "occupied" });
        // this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "choiceMemberId", choiceMemberId);
        // console.log(this.config.tasking.table.tableData[this.ChooseConfig.index].choiceMemberId, "?????????choiceMemberId");
        // this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "isTeam", 1);
        // this.ChooseConfig.isShow = false;
      } else if (item.type === "equipmentChoose") {
        if (selecetion.length === 0) {
          this.$message.error("请选择装备！");
          return;
        }
        // this.equipmentList = selecetion
        const choiceEquId = selecetion.map(i => { return i.id; });
        // updateEquip({ ids: choiceEquId.join(","), memberStatus: "occupied" }).then(res => {
        //   console.log(res, "???????res");
        // });
        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "isEquipment", 1);
        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "choiceEquId", choiceEquId);
        this.ChooseConfig.isShow = false;
      } else if (item.type === "vehicleChoose") {
        if (selecetion.length === 0) {
          this.$message.error("请选择车辆！");
          return;
        }
        // this.vehicleList = selecetion
        const choiceVehicleId = selecetion.map(i => { return i.id; });
        // updateVehicle({ ids: choiceVehicleId.join(","), memberStatus: "occupied" }).then(res => {
        //   console.log(res, "???????res");
        // });
        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "isVehicle", 1);
        this.$set(this.config.tasking.table.tableData[this.ChooseConfig.index], "choiceVehicleId", choiceVehicleId);
        this.ChooseConfig.isShow = false;
      }
    },
    // 审批主任务
    approval(scope) {
      this.$nextTick(() => {
        this.$set(this.dialogConfig, "isShow", true);
        this.$set(this.dialogConfig, "type", "approval");
        this.$set(this.dialogConfig, "title", "预警任务分配单");
        this.$set(this.config.TaskAllocationConfig.formConfig.formData[0], "isDisabled", true);
        this.$set(this.config.TaskAllocationConfig.formConfig, "rules", {});
        this.$set(this.config.TaskAllocationConfig.formConfig1.formData[1], "isDisabled", true);
        this.$set(this.config.TaskAllocationConfig.formConfig1, "rules", {});
        this.$set(this.config.TaskAllocationConfig.formConfig3.formData[0], "isDisabled", false);
        // this.$set(this.config.TaskAllocationConfig.formConfig1, "disabled", true)
        const btnList = [
          {
            name: "同意",
            type: "primary",
            id: "agree",
            size: "mini"
          },
          {
            name: "驳回",
            id: "rejected",
            size: "mini"
          },
          {
            name: "取消",
            id: "cancel",
            size: "mini"
          }
        ];
        this.$set(this.dialogConfig, "btnList", btnList);
        const titleConfig = [
          {
            title: "信息来源",
            name: "1",
            slot: "slot1"
          },
          {
            title: "任务信息",
            name: "2",
            slot: "slot2"
          },
          {
            title: "填报信息",
            name: "3",
            slot: "slot3"
          },
          {
            title: "审批信息",
            name: "4",
            slot: "slot4"
          }
        ];
        this.$set(this, "titleConfig", titleConfig);
        this.getNoticeOption(1);
        this.getTasksDetail(scope);
      });
    },
    // 审批子任务
    childApproval(scope) {
      this.checkChildConfig(scope);
      this.$nextTick(() => {
        this.$set(this.dialogConfig2, "isShow", true);
        this.getApprovalDetail(scope);
      });

    },
    // 任务派遣
    tasking(scope, val) {
      this.$set(this.dialogConfig1, "isShow", true);
      if (val) {
        this.$set(this.dialogConfig1, "type", val);
      } else {
        this.$set(this.dialogConfig1, "type", "tasking");
      }
      this.$set(this.dialogConfig1, "title", "预警子任务派遣单");
      const titleConfig = [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "主任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "子任务派遣信息",
          name: "3",
          slot: "slot3"
        },
        // {
        //   title: "审核信息",
        //   name: "4",
        //   slot: "slot4"
        // },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.$set(this.config.tasking.formConfig, "rules", {});
      this.$set(this.config.tasking.formConfig1, "rules", {});
      this.$set(this, "titleConfig1", titleConfig);
      this.getTaskMission(scope);
      this.getNoticeOption(2);
    },
    // 获取下拉框数据
    getInputVal() {
      this.config.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroup({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: item.dicCode
              };
            });
            item.options = option;
          });
        } else if (item.elType === "lsdTree") {
          getOrgDepartmentList({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(res => {
            this.$nextTick(() => {
              if (item.label === "派发单位/部门") {
                this.$set(this.config.formData[4].treeData.attrs, "data", res);
              } else if (item.label === "责任单位/部门") {
                this.$set(this.config.formData[5].treeData.attrs, "data", res);
              }
              // this.$set(this.config.formData[5].treeData.attrs, "data", res)
            });
            // console.log(this.selectTreeList, "selectTreeListselectTreeListselectTreeList");
          });
        }
      });
      // this.config.ChooseFormConfig.formData.forEach(item => {
      //   if (item.dic) {
      //     getTeam({ type: item.dic }).then(res => {
      //       console.log(res, "???????????res");
      //       const option = res.map((item) => {
      //         return {
      //           label: item.name,
      //           value: item.name
      //           // value: Number(item.code)
      //         };
      //       });
      //       item.option = option;
      //     });
      //     console.log(this.config.ChooseFormConfig.formData, "????this.config.ChooseFormConfig.formData");
      //   }
      // });
      // this.config.PersonnelFormConfig.formData.forEach((item) => {
      //   if (item.dic) {
      //     GetListTeamType({ type: item.dic }).then(res => {
      //       const option = res.map((val) => {
      //         return {
      //           label: val.name,
      //           value: val.name
      //         };
      //       });
      //       item.option = option;
      //     });
      //   }
      // });
      // this.config.EquipmentFormConfig.formData.forEach((item) => {
      //   if (item.dic) {
      //     GetEquipType({ type: item.dic }).then(res => {
      //       const option = res.map((val) => {
      //         return {
      //           label: val.name,
      //           value: val.name
      //         };
      //       });
      //       item.option = option;
      //     });
      //   } else if (item.lable === "所属单位") {
      //     ssdwList().then(res => {
      //       item.treeData.data = res;
      //     });
      //   }
      // });
      // this.config.VehicleFormConfig.formData.forEach((item) => {
      //   if (item.dic) {
      //     GetVehicleType({ type: item.dic }).then(res => {
      //       const option = res.map((val) => {
      //         return {
      //           label: val.name,
      //           value: val.name
      //         };
      //       });
      //       item.option = option;
      //     });
      //   }
      // });
    },
    // 弹窗选人组件筛选
    chooseQuery(select, val, item) {
      console.log(select, "---select");
      console.log(val, "---val");
      console.log(item, "---item");
      const type = this.ChooseConfig.type;
      if (type === "teamChoose") {
        this.getTeamList(select, val, item);
      } else if (type === "playersChoose") {
        const arr = [{ id: this.teamId }];
        this.getPlayerList(arr, val, item);
      } else if (type === "equipmentChoose") {
        this.getEquipmentList(select, val, item);
      } else if (type === "vehicleChoose") {
        this.getVehicleList(select, val, item);
      }
    },
    // 获取队伍列表
    getTeamList(select, val, item) {
      console.log(val, item);
      let parmas = {
        pageNum: this.config.ChooseTableConfig.paginationAtrrs["current-page"],
        pageSize: this.config.ChooseTableConfig.paginationAtrrs["page-size"],
        unitId: JSON.parse(sessionStorage.getItem("org")).orgId
      };
      if (val && !item) {
        parmas = {
          pageNum: this.config.ChooseTableConfig.paginationAtrrs["current-page"],
          pageSize: this.config.ChooseTableConfig.paginationAtrrs["page-size"],
          ...val,
          unitId: JSON.parse(sessionStorage.getItem("org")).orgId
        };
      } else if (item) {
        parmas = { ...item, ...val, unitId: JSON.parse(sessionStorage.getItem("org")).orgId };
      }
      GetTeam(parmas).then(data => {
        this.config.ChooseTableConfig.tableData = data.data;
        this.config.ChooseTableConfig.paginationAtrrs.total = data.total;
        // 根据选择数据进行表格回显
        const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceTeamId || [];
        if (result.length > 0) {
          this.$nextTick(() => {
            this.$refs.dialogChoose.$refs.teamTabel.toggleSelection(result);
          });
        }
      });
      // 获取队伍筛选下拉接口
      this.config.ChooseFormConfig.formData.forEach(item => {
        if (item.dic) {
          getTeam({ type: item.dic }).then(res => {
            console.log(res, "???????????res");
            const option = res.map((item) => {
              return {
                label: item.name,
                value: item.name
                // value: Number(item.code)
              };
            });
            item.option = option;
          });
        }
      });
    },
    // 获取队员列表
    getPlayerList(arr, val, item) {
      let parmas = {
        pageNum: this.config.PersonnelTableConfig.paginationAtrrs["current-page"],
        pageSize: this.config.PersonnelTableConfig.paginationAtrrs["page-size"],
        teamId: arr[0].id,
        occupation: "",
        unitId: JSON.parse(sessionStorage.getItem("org")).orgId
      };
      if (val && !item) {
        parmas = {
          pageNum: this.config.PersonnelTableConfig.paginationAtrrs["current-page"],
          pageSize: this.config.PersonnelTableConfig.paginationAtrrs["page-size"],
          teamId: arr[0].id,
          ...val,
          unitId: JSON.parse(sessionStorage.getItem("org")).orgId
        };
      } else if (item) {
        parmas = { ...item, ...val, unitId: JSON.parse(sessionStorage.getItem("org")).orgId };
      }
      const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceMemberId || [];
      // if (result.length > 0) {
      parmas.occupation = "";
      // } else {
      //   parmas.occupation = 0;
      // }
      GetTeamMember(parmas).then(data => {
        this.config.PersonnelTableConfig.tableData = data.data;
        this.config.PersonnelTableConfig.paginationAtrrs.total = data.total;
        // 根据选择数据进行表格回显
        console.log(result, "?????????????result");
        if (result.length > 0) {
          this.$nextTick(() => {
            this.$refs.dialogChoose.$refs.playerTabel.toggleSelection(result);
          });
        }
      });
      // 获取队员筛选下拉数据
      this.config.PersonnelFormConfig.formData.forEach((item) => {
        if (item.dic) {
          GetListTeamType({ type: item.dic }).then(res => {
            const option = res.data.map((val) => {
              return {
                label: val.name,
                value: val.name
              };
            });
            item.option = option;
          });
        }
      });
    },
    // 获取装备列表
    getEquipmentList(select, val, item) {
      let parmas = {
        pageNum: this.config.EquipmentTableConfig.paginationAtrrs["current-page"],
        pageSize: this.config.EquipmentTableConfig.paginationAtrrs["page-size"],
        unitId: JSON.parse(sessionStorage.getItem("org")).orgId
      };
      if (val && !item) {
        parmas = {
          pageNum: this.config.EquipmentTableConfig.paginationAtrrs["current-page"],
          pageSize: this.config.EquipmentTableConfig.paginationAtrrs["page-size"],
          ...val,
          unitId: JSON.parse(sessionStorage.getItem("org")).orgId
        };
      } else if (item) {
        parmas = { ...item, ...val, unitId: JSON.parse(sessionStorage.getItem("org")).orgId };
      }
      const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceEquId || [];
      // if (result.length > 0) {
      //   parmas.occupation = "";
      // } else {
      //   parmas.occupation = 0;
      // }
      GetEquip(parmas).then(data => {
        this.config.EquipmentTableConfig.tableData = data.data;
        this.config.EquipmentTableConfig.paginationAtrrs.total = data.total;
        // 根据选择数据进行表格回显
        if (result.length > 0) {
          this.$nextTick(() => {
            this.$refs.dialogChoose.$refs.EquipmentTabel.toggleSelection(result);
          });
        }
      });
      // 获取装备筛选下拉接口
      this.config.EquipmentFormConfig.formData.forEach((item) => {
        if (item.dic) {
          GetEquipType({ type: item.dic }).then(res => {
            const option = res.map((val) => {
              return {
                label: val.name,
                value: val.name
              };
            });
            item.option = option;
          });
        } else if (item.label === "所属单位") {
          // ssdwList().then(res => {
          getOrggetSameLevel().then(res => {
            item.treeData.data = res;
          });
        }
      });
    },
    // 获取车辆列表
    getVehicleList(select, val, item) {
      let parmas = {
        pageNum: this.config.VehicleTableConfig.paginationAtrrs["current-page"],
        pageSize: this.config.VehicleTableConfig.paginationAtrrs["page-size"],
        unitId: JSON.parse(sessionStorage.getItem("org")).orgId
      };
      if (val && !item) {
        parmas = {
          pageNum: this.config.VehicleTableConfig.paginationAtrrs["current-page"],
          pageSize: this.config.VehicleTableConfig.paginationAtrrs["page-size"],
          ...val,
          unitId: JSON.parse(sessionStorage.getItem("org")).orgId
        };
      } else if (item) {
        parmas = { ...item, ...val, unitId: JSON.parse(sessionStorage.getItem("org")).orgId };
      }
      const result = this.config.tasking.table.tableData[this.ChooseConfig.index].choiceVehicleId || [];
      // if (result.length > 0) {
      //   parmas.occupation = "";
      // } else {
      //   parmas.occupation = 0;
      // }
      GetVehicle(parmas).then(data => {
        this.config.VehicleTableConfig.tableData = data.data;
        this.config.VehicleTableConfig.paginationAtrrs.total = data.total;
        // 根据选择数据进行表格回显
        if (result.length > 0) {
          this.$nextTick(() => {
            this.$refs.dialogChoose.$refs.vehicleTabel.toggleSelection(result);
          });
        }
      });
      // 获取车辆筛选下拉接口
      this.config.VehicleFormConfig.formData.forEach((item) => {
        if (item.dic) {
          GetVehicleType({ type: item.dic }).then(res => {
            const option = res.map((val) => {
              return {
                label: val.name,
                value: val.name
              };
            });
            item.option = option;
          });
        }
      });
    },
    // 根据不同type返回对应的配置
    checkConfig(val) {
      const type = this.ChooseConfig.type;
      let formConfig = {};
      let tableConfig = {};
      if (type === "teamChoose") {
        formConfig = this.config.ChooseFormConfig;
        tableConfig = this.config.ChooseTableConfig;
        // this.getTeamList()
      } else if (type === "playersChoose") {
        formConfig = this.config.PersonnelFormConfig;
        tableConfig = this.config.PersonnelTableConfig;
      } else if (type === "equipmentChoose") {
        formConfig = this.config.EquipmentFormConfig;
        tableConfig = this.config.EquipmentTableConfig;
        // this.getEquipmentList()
      } else if (type === "vehicleChoose") {
        formConfig = this.config.VehicleFormConfig;
        tableConfig = this.config.VehicleTableConfig;
        // this.$nextTick(() => {
        // this.getVehicleList()
        // })
      }
      if (val === 1) {
        return formConfig;
      } else if (val === 2) {
        return tableConfig;
      }
    },
    // 分页
    handleSizeChange(val) {
      const data = {
        pageNum: val["current-page"],
        pageSize: val["page-size"],
        roleCode: JSON.parse(sessionStorage.getItem("role")).roleCode,
        orgCode: this.form.distributeTaskId || JSON.parse(sessionStorage.getItem("org")).orgId,
        flowCode: this.form.flowCode ? this.form.flowCode : this.$route.query.flowCode ? this.$route.query.flowCode : "",
        noticeOrderName: this.form.noticeOrderName || "",
        taskName: this.form.taskName || "",
        taskContent: this.form.taskContent || "",
        professionCode: this.form.professionCode || "",
        distributeDept: this.form.distributeDept || "",
        dutyUnit: this.form.dutyUnit || "",
        dutyUnitCode: this.form.dutyUnitCode || "",
        publishTimeStart: this.form.publishTime ? this.form.publishTime[0] : "",
        publishTimeEnd: this.form.publishTime ? this.form.publishTime[1] : "",
        flowStatus: this.form.flowStatus || ""
        // dutyUnitCode: JSON.parse(sessionStorage.getItem("org")).id
      };
      this.getList(data);
    },
    // 人员选择弹窗分页
    handleChooseChange(select, item, val) {
      console.log(val, "----val");
      console.log(select, item, val);
      const data = {
        pageNum: val["current-page"],
        pageSize: val["page-size"]
        // teamId: this.teamId
      };
      this.chooseQuery(select, item, data);
    },
    // 选择弹窗公共方法
    commonChoose(title, type, item, scope, unit) {
      this.ChooseConfig.isShow = true;
      this.ChooseConfig.unit = unit || "";
      this.ChooseConfig.title = title;
      this.ChooseConfig.type = type;
      this.ChooseConfig.index = scope.$index;
      this.ChooseConfig.btnList = [
        {
          name: "确认",
          type: "primary",
          id: "confirm",
          size: "mini"
        },
        {
          name: "取消",
          id: "cancel",
          size: "mini"
        }
      ];
      if (type === "teamChoose") {
        this.getTeamList();
        this.$set(this.ChooseConfig, "checkSelect", false);
      } else if (type === "equipmentChoose") {
        this.getEquipmentList();
        this.$set(this.ChooseConfig, "checkSelect", false);
      } else if (type === "vehicleChoose") {
        this.getVehicleList();
        this.$set(this.ChooseConfig, "checkSelect", false);
      }
    },
    // 列表表格按钮事件
    actionHandle(item, scope) {
      if (item === "编辑") {
        if (["8", "21", "11"].includes(scope.row.flowCode)) {
          this.tasking(scope, "taskingEdit");
        } else {
          this.add("edit", scope);
        }
      } else if (item === "删除") {
        this.handleDelete(scope);
      } else if (item === "审批") {
        if (scope.row.flowCode === "9") {
          this.childApproval(scope);
        } else {
          this.approval(scope);
        }
      } else if (item === "任务派遣") {
        this.tasking(scope);
      } else if (["队伍", "队伍已选择"].includes(item)) {
        // if (item === "队伍") {
        this.commonChoose("队伍选择", "teamChoose", item, scope);
        // } else {
        //   this.commonChoose("队伍选择", "playersChoose", item, scope)
        // }
      } else if (["装备", "装备已选择"].includes(item)) {
        this.commonChoose("装备选择", "equipmentChoose", item, scope, "类装备");
      } else if (["车辆", "车辆已选择"].includes(item)) {
        this.commonChoose("车辆选择", "vehicleChoose", item, scope, "台车");

      }
    },
    // 获取任务分配弹窗列表下拉数据
    async getTasksOption() {
      const arr = [
        // {
        //   dic: "dic_rwlx",
        //   option: "rwlxOption"
        // },
        {
          dic: "dic_zy",
          option: "zylxOption"
        }
      ];
      arr.forEach(item => {
        getDictByGroup({ groupCode: item.dic }).then(res => {
          const option = res.map((item) => {
            return {
              label: item.dicName,
              value: item.dicCode
            };
          });
          this[item.option] = option;
        });
      });
      const nowOrgId = JSON.parse(sessionStorage.getItem("org")).orgId;
      const { id } = await getSuperiorUntilId(nowOrgId);
      if (id) {
        getOrggetSameLevel({ orgId: id }).then(res => {
          this.$set(this, "zrdwOption", res);
        });
      }
    },
    getRwlxList(val) {
      getDictList({ groupCode: `dic_zy_${val}` }).then(res => {
        const option = res.map(i => {
          return {
            label: i.dicName,
            value: i.dicCode
          };
        });
        this.$set(this, "rwlxOption", option);
      });
    },
    // 获取任务通知单下拉数据
    getNoticeOption(val) {
      if (val === 1) {
        this.config.TaskAllocationConfig.formConfig.formData.forEach((item) => {
          if (item.label === "预警通知单") {
            getIssueNoticeList({ pageNum: 1, pageSize: 10 }).then(res => {
              const option = res.data.map((item) => {
                return {
                  label: item.warningNoticeName,
                  value: item.id
                };
              });
              item.option = option;
            });
          }
        });
      } else if (val === 2) {
        this.config.tasking.formConfig.formData.forEach((item) => {
          if (item.label === "预警通知单") {
            getIssueNoticeList({ pageNum: 1, pageSize: 10 }).then(res => {
              const option = res.data.map((item) => {
                return {
                  label: item.warningNoticeName,
                  value: item.id
                };
              });
              item.option = option;
              console.log(item, "????????????????item");
            });
          }
        });
      }
    },
    getSearchNoticeOption() {
      this.config.formData.forEach((item) => {
        if (item.label === "预警通知单") {
          getIssueNoticeList({ pageNum: 1, pageSize: 10 }).then(res => {
            const option = res.data.map((item) => {
              return {
                label: item.warningNoticeName,
                value: item.id
              };
            });
            item.options = option;
          });
          // }
        }
      });
    },
    // 重置
    reset() {
      this.form = this.$options.data().form;
      this.$refs.yjrwlb.paginationAtrrsInner["current-page"] = 1;
      this.getList();
    },
    // 筛选
    query() {
      const parmas = {
        pageNum: this.config.table.paginationAtrrs["current-page"],
        pageSize: this.config.table.paginationAtrrs["page-size"],
        flowCode: this.form.flowCode ? this.form.flowCode : this.$route.query.flowCode ? this.$route.query.flowCode : "",
        noticeOrderName: this.form.noticeOrderName || "",
        taskName: this.form.taskName || "",
        taskContent: this.form.taskContent || "",
        professionCode: this.form.professionCode || "",
        distributeDept: this.form.distributeDept || "",
        // distributeTaskId: this.form.distributeTaskId || "",
        dutyUnit: this.form.dutyUnit || "",
        dutyUnitCode: this.form.dutyUnitCode || "",
        publishTimeStart: this.form.publishTime ? this.form.publishTime[0] : "",
        publishTimeEnd: this.form.publishTime ? this.form.publishTime[1] : "",
        flowStatus: this.form.flowStatus || "",
        orgCode: this.form.distributeTaskId || JSON.parse(sessionStorage.getItem("org")).orgId,
        roleCode: JSON.parse(sessionStorage.getItem("role")).roleCode
      };
      this.getList(parmas);
    },
    // 跳转任务详情
    toTaskDetail(id) {
      this.$router.push({
        name: "WarningActionDetail",
        query: {
          id
        }
      });
    }

  }
};
</script>

<style lang="less" scoped>
@import "../../../assets/style/common.less";
@import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/pop-upNotification.less";

:deep(.el-breadcrumb__inner.is-link) {
  font-weight: 100;
  color: #fff;
}

.EmergencyList :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
  color: #3270ff;
}

.box {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 15px;
  background-color: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}

.yqwcsj {
  :deep(.el-date-editor.el-input, .el-date-editor.el-input__inner) {
    width: auto;
  }
}

.yuandian1 {
  display: inline-block;
  background-color: #ccc;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.ydBgcolor {
  background-color: #246dfd;
  box-shadow: 0px 0px 8px 0px rgb(10, 99, 241);
}

:deep(.el-step__icon.is-text) {
  border: none;
}

:deep(.el-step__title.is-process) {
  font-weight: normal;
}
</style>
